(ns pe.p9-bruteforce)

(defn sqr [x] (* x x))

(defn triplet [a b]
  (let [c (Math/sqrt (+ (sqr a) (sqr b)))]
    [(and (and (< a b) (< b c))
           (and (= (int c) c))) a b (int c) (+ a b (int c)) (* a b (int c))]))


(defn all-permutations [to]
  (for [a (range 1 to) b (range (inc a) to)] [a b]))

(defn all-triplets [to]
  (filter #(first %) (map #(triplet (first %) (nth % 1)) (all-permutations to))))


(println (filter #(= (int (nth % 4)) 1000) (all-triplets 1000)))